package android.slc.user.ui.user.fragment

import android.os.Bundle
import android.slc.appbase.ui.fragment.base.AppMvvmBaseFragment
import android.slc.extras.component.tree.ui.TreeNavVm
import android.slc.user.R
import android.slc.user.databinding.UserFragmentUserListBinding
import android.slc.user.ui.user.delegate.UserListMultipleDelegate
import android.slc.user.ui.user.vm.UserListMultipleVm
import android.slc.user.ui.user.vm.UserMultipleShelfVm
import android.slc.user.ui.user.vmbox.UserListMultipleVmBox
import com.blankj.utilcode.util.ToastUtils

/**
 *
 * @Description:
 * @Author: sunlunchang
 * @CreateDate: 2021/12/06 下午 3:24
 *
 */
class UserListMultipleFragment :
    AppMvvmBaseFragment<UserFragmentUserListBinding, UserListMultipleVm>() {
    private lateinit var treeNavVm: TreeNavVm
    private lateinit var userMultipleShelfVm: UserMultipleShelfVm

    override fun setContentView(): Any {
        return R.layout.user_fragment_user_list
    }

    override fun onInitViewModel() {
        super.onInitViewModel()
        this.treeNavVm = getVmByActivityProvider(TreeNavVm::class.java)
        this.userMultipleShelfVm = getVmByActivityProvider(UserMultipleShelfVm::class.java)
    }

    override fun onBindView(savedInstanceState: Bundle?) {
        super.onBindView(savedInstanceState)
        UserListMultipleDelegate().apply {
            init(
                this@UserListMultipleFragment, dataBinding.root,
                viewModel.dataListVmBox as UserListMultipleVmBox
            )
        }
    }

    override fun onBindViewLater() {
        super.onBindViewLater()
        arguments?.let {
            viewModel.initVm(it, userMultipleShelfVm.treeMultipleShelfVmBox)
        } ?: let {
            ToastUtils.showShort(R.string.user_label_user_info_not_found)
            requireActivity().finish()
        }
    }
}